package gui;

import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import server.ejb.beans.Lotse;

@SuppressWarnings("serial")
public class MaskSollZeit extends Masks {
	
	private JLabel lblZeit;
	private JLabel lblDatum;
	private JLabel lblLotse;
	
	private JTextField txtZeit;
	private JTextField txtDatum;
	private JComboBox  cbxLotse;

	private List<Lotse> lotseListe;
	/**
	 * Create the panel.
	 */
	public MaskSollZeit() 
	{
		super();
		
		lblZeit = new JLabel("Zeit:");
		lblZeit.setBounds(37, 17, 46, 14);
		add(lblZeit);
		
		lblDatum = new JLabel("Datum:");
		lblDatum.setBounds(37, 42, 46, 14);
		add(lblDatum);
		
		txtZeit = new JTextField();
		txtZeit.setBounds(93, 14, 277, 20);
		add(txtZeit);
		txtZeit.setColumns(1);
		
		txtDatum = new JTextField();
		txtDatum.setBounds(93, 39, 277, 20);
		add(txtDatum);
		txtDatum.setColumns(1);
		
		lblLotse = new JLabel("Lotse:");
		lblLotse.setBounds(37, 67, 46, 14);
		add(lblLotse);
		
		cbxLotse = new JComboBox();
		cbxLotse.setBounds(93, 64, 277, 20);
		add(cbxLotse);
		
	}

	@Override
	public boolean checkInhalt() {
		if (txtZeit.getText() == ""){
			return false;
		}
		if (txtDatum.getText() == ""){
			return false;
		}
		if (cbxLotse.getSelectedIndex() == -1) {
			return false;
		}
		return true;
	}
	
	public void setLotsenListe(List<Lotse> lotseListe)
	{
		this.lotseListe = lotseListe;
		cbxLotse.removeAllItems();
		for(Lotse l: lotseListe) {
			cbxLotse.addItem(l.getName());
		}
	}
	
	public Lotse getSelectedLotse() {
		return lotseListe.get(cbxLotse.getSelectedIndex());
	}
	
	public String getSollZeit()
	{
		return txtZeit.getText();
	}
	public String getSollDatum()
	{
		return txtDatum.getText();
	}
}
